/**
 *    @file       domainparse.h
 *
 *    @brief      
 *    @details
 *
 *    @version    1.0
 *    @date       12/29/2012 03:34:58 PM
 *
 *    @author     Theophilus (), wangtf418@gmail.com
 */
#ifndef _BF_DOMAINPARSE_H_
#define _BF_DOMAINPARSE_H_
#include <string>
#include <map>
#include <vector>
#include "comdef.h"
#include "threadmutex.h"
#define BF_PARSE_DOMAIN_INTERVAL 300

struct domain_ip
{
	std::vector<bf_uint32_t> m_inaddr_list;
	std::vector<std::string> m_strip_list;
	bf_time_t m_updatetime;
};

class domainparse
{
public:
	domainparse();
	~domainparse();

public:
	static bf_int_t parse_domain(const std::string &domain, domain_ip &ret_out, bf_int_t reparse_interval = BF_PARSE_DOMAIN_INTERVAL);
	static bf_int_t parse_domain(const std::string &domain, bf_uint32_t &inaddr_out, bf_int_t reparse_interval = BF_PARSE_DOMAIN_INTERVAL);
	static bf_int_t parse_domain(const std::string &domain, std::string &ip_out, bf_int_t reparse_interval = BF_PARSE_DOMAIN_INTERVAL);

private:
	static std::map<std::string, domain_ip> m_domain;
	static threadmutex m_lock;
};

#endif

